package com.dhcc.mybatis.web.rest.user;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import com.dhcc.mybatis.blh.user.UserBlh;
import com.dhcc.mybatis.dto.user.UserDto;
import com.dhcc.mybatis.entity.user.User;

 /**
 * <p>描述：用户信息REST接口</p>
 * <p>公司：东华医为科技有限公司</p>
 * <p>版权：dhcc-2019</p>
 * @author liuyg
 * @since 2019-12-25
 */
@RestController
@RequestMapping("/dhccApi/user/user")
public class UserRest {

	@Autowired
	private UserBlh userBlh;
	
	@PostMapping(value="list",consumes="application/json")
	public Page<User> listRest(@RequestBody(required=false) UserDto dto) {
		return this.list(dto);
	}
	@RequestMapping("list")
	public Page<User> list(UserDto dto) {
		userBlh.list(dto);
		return dto.getPage();
	}
	
	@PostMapping(value="save",consumes="application/json")
	public UserDto saveRest(@RequestBody UserDto dto) {
		return this.save(dto);
	}
	@PostMapping("save")
	public UserDto save(UserDto dto) {
		userBlh.save(dto);
		return dto;
	}
	
	@PostMapping(value="updateById",consumes="application/json")
	public UserDto updateByIdRest(@RequestBody UserDto dto) {
		return this.updateById(dto);
	}
	@PutMapping("updateById")
	public UserDto updateById(UserDto dto) {
		userBlh.updateById(dto);
		return dto;
	}
	
	@PostMapping(value="removeById",consumes="application/json")
	public UserDto removeByIdRest(@RequestBody UserDto dto) {
		return this.removeById(dto);
	}
	@DeleteMapping("removeById")
	public UserDto removeById(UserDto dto) {
		userBlh.removeById(dto);
		return dto;
	}
	
	@PostMapping(value="getById",consumes="application/json")
	public UserDto getByIdRest(@RequestBody UserDto dto) {
		return this.getById(dto);
	}
	@GetMapping("getById")
	public UserDto getById(UserDto dto) {
		userBlh.getById(dto);
		return dto;
	}
	
	@PostMapping(value="getUserById",consumes="application/json")
	public UserDto getUserByIdRest(@RequestBody UserDto dto) {
		return this.getUserById(dto);
	}
	@GetMapping("getUserById")
	public UserDto getUserById(UserDto dto) {
		userBlh.getUserById(dto);
		return dto;
	}
}
